//
//  EventMonitor.h
//  Simulation
//
//  Created by Christopher Kemsley on 2/24/12.
//  Copyright (c) 2012 iAppolopolis. All rights reserved.
//

#ifndef Simulation_EventMonitor_h
#define Simulation_EventMonitor_h

#include "Types.hpp"
#include "RunLoop.hpp"
#include "Invocation.hpp"
#include "Condition.hpp"



NamespaceBegin

// NOT using Invocation ;
// NOT using Condition ;






class	EventMonitor : public RunLoopSource
{
public:
	
	typedef enum {
		kModeOnRise ,
		kModeOnFall ,
		kModeOnChange ,
		kModeWhenOn ,
		kModeWhenOff
	} Mode ;
	
	
	
	EventMonitor	( Condition * inCondition , Invocation * inInvocation , Mode inMode = kModeOnRise ) ;
	virtual ~EventMonitor () ; // disables monitor
	
	
	
	
private:
	typedef void (EventMonitor::*FireFunction) (void) ;
	
	virtual void	fire () ;
	
	void _fire_onRise () ;
	void _fire_onFall () ;
	void _fire_onChange () ;
	void _fire_whenOn () ;
	void _fire_whenOff () ;
	
	
	Condition	*	mCondition ;
	Invocation	*	mInvocation ;
	FireFunction	mFunction ;
	bool			mPrevious ;
} ;





NamespaceEnd
#endif
